def Murmurhash2(data, seed):
    m = long(0x5bd1e995)
    r = long(24)
    
    l = len(data)
    
    h = long(seed) ^ long(l)
    
    b = 0
    while l >= 4:
        k = long(ord(data[b + 0])) << 0
        k |= long(ord(data[b + 1])) << 8
        k |= long(ord(data[b + 2])) << 16
        k |= long(ord(data[b + 3])) << 24
        
        k *= m
        
        k &= long(0xFFFFFFFF)
        k ^= k >> r
        
        k *= m
        
        h *= m
        h ^= k
        
        b += 4
        l -= 4
        
        h &= long(0xFFFFFFFF)
    
    if l == 3:
        h ^= long(ord(data[b + 2])) << 16
        h ^= long(ord(data[b + 1])) << 8
        h ^= long(ord(data[b + 0])) << 0
        h *= m
    if l == 2:
        h ^= ord(data[b + 1]) << 8
        h ^= ord(data[b + 0]) << 0
        h *= m
    if l == 1:
        h ^= ord(data[b + 0]) << 0
        h *= m
    
    h &= long(0xFFFFFFFF)
    h ^= h >> 13
    
    h *= m
    
    h &= long(0xFFFFFFFF)
    h ^= h >> 15
    
    return h & long(0xFFFFFFFF)


def Test():
    assert(Murmurhash2("Hello, World!", 0) == 0x2da26fc3)
    print(hex(Murmurhash2("magic", 0)))
    print(hex(Murmurhash2("magic2", 0)))
    print(hex(Murmurhash2("type", 0)))
    print(hex(Murmurhash2("sizeInBlocks", 0)))
    print(hex(Murmurhash2("sizeInBytes", 0)))
    print(hex(Murmurhash2("randomMagic", 0)))


def __main__():
    Test()


if __name__ == "__main__":
    __main__()